

import java.util.LinkedList;
import java.util.List;

import soot.Unit;
import soot.toolkits.graph.UnitGraph;
import soot.toolkits.scalar.ForwardBranchedFlowAnalysis;

public class AnalysisTester extends ForwardBranchedFlowAnalysis<LinkedList<String>> {

	public AnalysisTester(UnitGraph graph) {
		super(graph);
		
		doAnalysis();
	}

	@Override
	protected void flowThrough(LinkedList<String> in, Unit cmd, List<LinkedList<String>> out,
			List<LinkedList<String>> branchOut) {
		for(LinkedList<String> l : out) {
			l.add("out: " + cmd.toString());
		}
		for(LinkedList<String> l : branchOut) {
			l.add("branch: " + cmd.toString());
		}
		
		System.out.println(cmd.toString());
		System.out.println("in:");
		System.out.println(in.toString());
		System.out.println("out:");
		for(LinkedList<String> l : out) {
			System.out.println("\t" + l.toString());
		}
		System.out.println("branchOut:");
		for(LinkedList<String> l : branchOut) {
			System.out.println("\t" + l.toString());
		}
		System.out.println("===============================\n");
	}

	@Override
	protected void copy(LinkedList<String> src, LinkedList<String> dst) {
		dst.addAll(src);

	}

	@Override
	protected LinkedList<String> entryInitialFlow() {
		return new LinkedList<String>();
	}

	@Override
	protected void merge(LinkedList<String> src1, LinkedList<String> src2, LinkedList<String> dst) {
		System.out.println("merging...");
		dst.addAll(src1);
		dst.addAll(src2);
	}

	@Override
	protected LinkedList<String> newInitialFlow() {
		return new LinkedList<String>();
	}

}
